package 剑指offer;

public class p10_1斐波那契数列 {


    public static void main(String[] args) {
        System.out.println(Integer.MAX_VALUE);

        String s="hello";
        System.out.println(s.length());
    }

    public int fib(int n) {
        //迭代法 又称 动态规划
        if(n==0 || n==1) {
            return n;
        }

        int fn2=0;  //F(0) = 0,
        int fn1=1;  //F(1) = 1
        int fn=0;

        for (int i=2;i<=n;i++) {
            fn=(fn1+fn2)%1000000007;
            fn2=fn1;
            fn1=fn;
        }
        return fn;

    }


        public int fib3(int n) {
            int a=0;
            int b=1;

            for (int i=0;i<n;i++) {
                int sum=(a+b)%1000000007;
                a=b;
                b=sum;
            }

            return a;
        }

    public int fib2(int n) {
        //递归写法 会超时！！
        if(n==0 || n==1) {
            return n;
        }

        return (fib2(n-1)+fib2(n-2))%1000000007;
    }

}
